class VirtualDataPage < DataPage
  attr_reader :data_slug

  def virtual?
    true
  end

  def find_by_url(url, live = true, clean = false)
    url = clean_url(url) if clean
    parent_url = parent.url

    if (url =~ /^#{Regexp.quote(parent_url)}([^\/]*)\/?$/)
      @data_slug = $1
    end
        
    self
  end
    
  protected
  def src(tag)
    src_template = tag.attr['src'] or raise TagError, "'data' tags require a 'src' attribute"
    src_template.gsub!(/\{data_slug\}/, data_slug)
  end
end
